package main;

import eg.com.itiga.business.base.BaseService;
import eg.com.itiga.business.exception.BusinessException;
import eg.com.itiga.business.factory.BusinessFactory;
import eg.com.itiga.business.role.RoleService;
import eg.com.itiga.domain.Branch;
import eg.com.itiga.domain.Department;
import eg.com.itiga.domain.Itian;
import eg.com.itiga.domain.Role;
import eg.com.itiga.domain.User;

public class mainITIan {

	/**
	 * @param args
	 * test add new ITIan
	 */
	public static void main(String[] args) {
		try {
			BaseService base= BusinessFactory.createBaseService();

			User user=new User();
			user.setUserName("username1");
			user.setUserPassword("password1");
			
			RoleService roleService=BusinessFactory.createRoleService();
			Role r=roleService.getRoleByName("ITIan");
			user.setRole(r);
			
			Department d=new Department();
			d.setDName("java");
			
			Branch b=new Branch("Smart",null);
			Itian i=new Itian();
			i.setUser(user);
			i.setDepartment(d);
			i.setBranch(b);
			base.add(i);
			
			
			System.out.println(r.getRName());
			System.out.println(r.getRId());
		} catch (BusinessException e) {

			e.printStackTrace();
		}

	}

}
